﻿using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Text;

namespace HeadersModePublish
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var channel = Common.RabbitMQ.GetChannel();

            //交换机
            channel.ExchangeDeclare("myheadersexchange", ExchangeType.Headers, true, false, default);

            //队列
            //channel.QueueDeclare("myfanoutqueue", true, false, false, default);

            var basicProperties = channel.CreateBasicProperties();
            basicProperties.Headers = new Dictionary<string, object>
            {
                {"name", "abc"},
                {"age", 20}
            };
            //basicProperties.Headers.Add("age", 30);

            for (int i = 0; i < 3; i++)
            {
                channel.BasicPublish("myheadersexchange", string.Empty, basicProperties, Encoding.UTF8.GetBytes($"你好{i}"));
            }
        }
    }
}
